Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: ''
    },
    back: {
      type: Boolean,
      value: true
    },
    showmsg: {
      type: Boolean,
      value: true
    }
  },

  options: {
    styleIsolation: 'shared'
  },

  /**
   * 组件的初始数据
   */
  data: {
    bgColor: '#079D60',
    titleColor: '#FFFFFF',
    windowHeight: 0,
    navHeight: 0
  },

  lifetimes: {
    attached() {
      this.getNavHeight()
    }
  },
  attached() {
    this.getNavHeight()
  },
  observers: {
    'back': function(back) {
      if (back) {
        this.setData({
          bgColor: '#079D60',
          titleColor: '#FFFFFF'
       })
      } else {
        this.setData({
          bgColor: '#FFFFFF',
          titleColor: '#030303'
         })
      }
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    back: function back() {
      wx.navigateBack({
        delta: 1
      });
    },
    toPageMessage: function() {
      wx.navigateTo({
        url: '/packageA/pages/message/message'
      })
    },
    getNavHeight() {
      const _this = this
      const query = wx.createSelectorQuery().in(this);
      query.select('.custom-nav-bar__wrap').boundingClientRect();

      query.exec((res) => {
        getApp().globalData.navHeight = res[0].height
        _this.setData({ navHeight: res[0].height })
      })
    }
  }
})
